<?php

/**
 * BlogCategoryTranslation form.
 *
 * @package    HugoHamon
 * @subpackage form
 * @author     Hugo Hamon <hugo.hamon@sensio.com>
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class BlogCategoryTranslationForm extends BaseBlogCategoryTranslationForm
{
  public function configure()
  {
    $this->useFields(array('name', 'slug'));
    
    $this->validatorSchema['slug'] = new sfValidatorAnd(array(
      new sfValidatorRegex(
        array('pattern' => $this->getSlugPattern()),
        array('invalid' => 'The slug format is not valid.')
      ),
      new sfValidatorDoctrineUnique(
        array('column' => array('slug'), 'model' => 'BlogCategoryTranslation', 'primary_key' => 'slug'),
        array('invalid' => 'This slug is already taken by an other post.')
      )
    ));
    
    $this->widgetSchema->setHelp('name', 'The name must be meaningfull.');
    $this->widgetSchema->setHelp('slug', 'The slug must be a unique string composed of A-Z, 0-9 and dash characters.');
    
    $this->validatorSchema['slug']->setOption('required', false);

    $this->widgetSchema['name']->setAttribute('size', 60);
    $this->widgetSchema['slug']->setAttribute('size', 40);
  }
}
